#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>

#define ERR_EXIT(m)         \
    do                      \
    {                       \
        perror(m);          \
        exit(EXIT_FAILURE); \
    } while (0)

int main()
{
    mkfifo("tp",0666);

    int infd=open("abc",O_RDONLY);
    if(infd<0)
    {
        ERR_EXIT("open infd");
    }

    int outfd=open("tp",O_WRONLY);
    if(outfd<0)
    {
        ERR_EXIT("open outfd");
    }

    char buffer[1024];
    int n=0;
    while(n=read(infd,buffer,sizeof(buffer)-1)>0)
    {
        buffer[n]=0;
        write(outfd,buffer,n);
    }

    close(infd);
    close(outfd);

    return 0;

}